package com.apop.accompany.controller;

import com.apop.common.exception.BizException;
import com.apop.common.mapper.mapper1.OneMapper;
import com.apop.common.mapper.mapper2.OneMapper2;
import com.apop.common.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 这里面的接口不拦截
 * @ClassName OneController
 * @author Jiayi Zheng
 * @date 2021/11/10 15:35
 * @Description: 测试
 * @version V1.0
 */
@RestController
@Slf4j
@RequestMapping("/pz")
public class PzTestController {

    @Autowired
    private OneMapper oneMapper;

    @Autowired
    private OneMapper2 oneMapper2;

    @Value("${mzt.redirect.url}")
    private  String redirectUrl ;

    /**
     * 获取验证码
     * @param map
     * @return
     */
    @PostMapping("/getCode")
    @ResponseBody
    public Result validateCode(@RequestBody Map map) {

        Map<String,Object> result = new HashMap();
        result.put("code","000000");
        return Result.success(result);
    }

    /**
     * 测试
     * @return
     */
    @GetMapping("/test")
    @ResponseBody
    public Result test() {

        Map<String,Object> result = new HashMap();
        result.put("redirectUrl",redirectUrl);
        return Result.success(result);
    }

    @PostMapping("/testOneMapper")
    @ResponseBody
    public Result EhcacheTest( HttpServletResponse response)  {
        String sql="SELECT * from T_PSM_MESSAGELOG";
        List<Map> list = oneMapper.executeQuery(sql);
        return Result.success(list);
    }

    @PostMapping("/testOneMapper2")
    @ResponseBody
    public Result testOneMapper2( HttpServletResponse response)  {
        String sql="SELECT * from T_PSM_MESSAGELOG";
        List<Map> list = oneMapper2.executeQuery(sql);
        return Result.success(list);
    }

}
